package com.haoze.nurseapp.enumeration;

import java.util.Optional;

public enum HelpItemEnum {

    ITEM_CLASS_DRUG("A", "药品", "A337A60229AE0CC7E053ED5B14AC81C2"),
    ITEM_CLASS_LAB("C", "检验", "A337A60229AF0CC7E053ED5B14AC81C2"),
    ITEM_CLASS_EXAM("D", "检查", "A337A60229B00CC7E053ED5B14AC81C2"),
    ITEM_CLASS_MANAGEMENT("E", "处置", "A337A60229B10CC7E053ED5B14AC81C2"),
    ITEM_CLASS_OPER("F", "手术", "A337A60229B20CC7E053ED5B14AC81C2"),
    ITEM_CLASS_G("G", "麻醉", "A337A60229B30CC7E053ED5B14AC81C2"),
    ITEM_CLASS_NURSE("H", "护理", "A337A60229B60CC7E053ED5B14AC81C2"),
    ITEM_CLASS_I("I", "膳食", "A337A60229B40CC7E053ED5B14AC81C2"),
    ITEM_CLASS_MATERIAL("L", "材料", "A337A60229AD0CC7E053ED5B14AC81C2"),
    ITEM_CLASS_Z("Z", "检疗", "A337A60229B50CC7E053ED5B14AC81C2")
    ;

    private String enumValue;
    private String enumName;
    private String enumCtlId;

    private HelpItemEnum(String enumValue, String enumName, String enumCtlId) {
        this.enumName = enumName;
        this.enumValue = enumValue;
        this.enumCtlId = enumCtlId;
    }

    public String getEnumValue() {
        return enumValue;
    }

    public String getEnumName() {
        return enumName;
    }

    public String getEnumCtlId() {
        return enumCtlId;
    }

    /**
     * 通过enumCtlId取枚举
     * @return
     */
    public static HelpItemEnum getHelpById(String enumCtlId){
        if (!Optional.ofNullable(enumCtlId).isPresent()){
            return null;
        }
        for (HelpItemEnum enums : HelpItemEnum.values()) {
            if (enums.getEnumCtlId().equals(enumCtlId)) {
                return enums;
            }
        }
        return null;
    }

    public static HelpItemEnum getHelpByName(String enumName){
        if (!Optional.ofNullable(enumName).isPresent()){
            return null;
        }
        for (HelpItemEnum enums : HelpItemEnum.values()) {
            if (enums.getEnumName().equals(enumName)) {
                return enums;
            }
        }
        return null;
    }

    public static HelpItemEnum getEnum(String enumCtlId) {
        HelpItemEnum[] helpItemEnums = values();
        for (HelpItemEnum helpItemEnum : helpItemEnums) {
            if (helpItemEnum.getEnumCtlId().equals(enumCtlId)) {
                return helpItemEnum;
            }
        }
        return null;
    }
}
